<template>
  <div class="dashboard-editor-container">
    <div class="filter-container">
      <el-input v-model="listQuery.kwd" placeholder="关键字搜索" style="width: 130px;margin-top:8px" class="filter-item" @keyup.enter.native="handleFilter" />
      <el-date-picker v-model="listQuery.start" style="width:150px;" format="yyyy-MM-dd" type="datetime" placeholder="订单开始日期" />
      <el-date-picker v-model="listQuery.end" style="width:150px" format="yyyy-MM-dd" type="datetime" placeholder="订单结束日期" />

      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter" style="margin-top:11px">
        查询
      </el-button>

    </div>
    <github-corner class="github-corner" />

    <!-- <order :order="order"/> -->

    <el-row :gutter="8">
      <total-table  :total_list="total" :loading='listLoading'/>
    </el-row>
  </div>
</template>

<script>
  import GithubCorner from '@/components/GithubCorner'
  import Order from './components/Order'
  import TotalTable from './components/TotalTable'

  import {
    getReportSaleData
  } from '@/api/report'
  const lineChartData = {
    newVisitis: {
      totalMoneyData: [],
      overdueData: [],
      monthData: []
    }
  }

  export default {
    name: 'DashboardAdmin',
    components: {
      GithubCorner,
      Order,
      TotalTable,
    },
    data() {
      return {
        listQuery: {
          kwd:'',
          start: '',
          end: '',
          member_flag:'merchant'
        },
        total:[],
        listLoading:1
      }
    },
    created() {
      this.urlFormat();
      this.getReportSaleData();
    },
    methods: {
      getReportSaleData(){
          getReportSaleData(this.listQuery).then(resp=>{
            this.listLoading = 0;
            this.total = resp.data;
          })
      },
      handleSetLineChartData(type) {
        this.lineChartData = lineChartData[type]
      },
      handleFilter(){
          this.getReportSaleData()
      },
      urlFormat(){
          let path = this.$route.path;
          let arr =  path.split('/');
          let flag = arr.pop()
          this.listQuery.member_flag = flag;
      }
    }
  }
</script>

<style lang="scss" scoped>
  .dashboard-editor-container {
    padding: 32px;
    background-color: rgb(240, 242, 245);
    position: relative;

    .github-corner {
      position: absolute;
      top: 0px;
      border: 0;
      right: 0;
    }

    .chart-wrapper {
      background: #fff;
      padding: 16px 16px 0;
      margin-bottom: 32px;
    }
  }

  @media (max-width:1024px) {
    .chart-wrapper {
      padding: 8px;
    }
  }
</style>
